﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Jumpton.SFA.Server.BusinessRule.System;
using Jumpton.SFA.Server.Entity;

public partial class System_ChangePassword : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnChangePassword_Click(object sender, EventArgs e)
    {
        USERS user =  UserManager.IsLoginPass(MyStateManager.Name,txtOld.Value.Trim().Replace("'", ""));
        //判断旧密码
        if (user != null)
        {
            ShowMessage("原密码输入错误！");
            return;
        }

        //修改密码
        try
        {
            if (new UserManager().ChangePassword(MyStateManager.UserID, txtConfirm.Value.Trim().Replace("'", "")))
            {
                Jumpton.SFA.Server.BusinessRule.System.EventManager.CreateNewEvent(
                  Jumpton.SFA.Server.BusinessRule.System.LogType.PASSWOD_CHANGED, this.MyStateManager.Name,
                  this.MyStateManager.UserID,"密码修改成功！");

                ShowAndRedirect(this, "密码修改成功！", "../index.aspx");
            }
            else
                ShowMessage("密码修改失败！");
        }
        catch (Exception ex)
        {
            Jumpton.SFA.Server.BusinessRule.System.EventManager.CreateNewEvent(
                 Jumpton.SFA.Server.BusinessRule.System.LogType.PASSWOD_CHANGED, this.MyStateManager.Name,
                 this.MyStateManager.UserID, "修改密码 - 异常:" + ex.Message);
        }

    }
}
